<template>
	<view class="content">

		<view class="iconfont icon-fanhui5 white size60 backImg" @click="$back()"></view>

		

		<canvas :style="{'width':width+'rpx','height':height+'rpx'}">
			<image :src="info.qr_code_img" class="wh" style="-webkit-touch-callout: default;" @load="imgLoad"></image>
		</canvas>
		<view class="addbox auto d-flex j-sa a-center  m-top50 m-bot30 ">

			<!-- #ifdef H5 -->
			<view class="SaveImg white flexac size32" v-if="info">长按海报保存</view>
			<!-- #endif -->
			<!-- #ifndef H5 -->
			<view class="SaveImg white flexac size32" @click="download" v-if="info">保存海报</view>
			<!-- #endif -->
			<view class="SaveImg white flexac size32" @click="copLink">复制链接</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: '',
				width: 750,
				height: 1000,
			}
		},
		onLoad() {
			this.share();
		},
		methods: {
			share() {
				this.$http.get('user/share').then(res => {
					if (res.code != 1) return this.$Toast(res.msg);
					this.info = res.data;
				})
			},
			download() {
				let that = this;
				uni.downloadFile({
					url: that.info.qr_code_img,
					success: (res) => {
						console.log(res);
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success() {
								that.$Toast('保存成功');
							}
						})
					},
					fail(err) {
						that.$Toast(err.errMsg)
					}
				})
			},
			imgLoad(e) {
				this.width = e.detail.width;
				this.height = e.detail.height;
			},
			
			copLink(){
				let url = `https://www.etometa.com/h5/#/pages/login/login?invite=${this.info.uuid}`;
				this.$getClip(url)
				console.log(url);
			}
		}
	}
</script>
<style>
	page {
		background: #01032a;
	}
</style>
<style lang="scss" scoped>
	// .content{
	// 	width:100%;
	// 	background-image: url(@/static/imgs/sharCodebg.png);
	// 	background-size: 100% 100%;
	// 	background-repeat: no-repeat;
	// }

	.SaveImg {
		width: 257rpx;
		height: 60rpx;
		border-radius: 20rpx;
		background-color: #7f2e8d;
	}
	.addbox{
		width:660rpx;
		height: 160rpx;
		background-image: url(@/static/imgs/shareBor2.png);
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
</style>
